home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 04 - 1988 / 04.09 Sep 88 / 4d stuff / Source Files / GetResNum.p < prev    next >
Encoding:
Text File  |  1988-06-22  |  1.3 KB  |  73 lines  |  [TEXT/MPS ]

  1.  
  2. {The CurProcResid function is assembly}
  3. {code which returns the 4BND resource}
  4. {number.}
  5.  
  6. function CurProcResid:Integer;
  7. INLINE $3EAD, $DE4E;
  8.  
  9. function GetResNum(T:ResType;     Localid:Integer):Integer; FORWARD;
  10. {
  11. .
  12. . Your code here
  13. .
  14. }
  15.  
  16. {Pass GetResNum the resource type and}
  17. {the local id and it will return the}
  18. {global id.}
  19.  
  20. function GetResNum;
  21.  
  22. type
  23.  
  24.     ResEntry = record
  25.                             Typ:ResType;
  26.                             LocalNum, GlobalNum:Integer;
  27.                             end;
  28.     ResTab =    record
  29.                             nbEntry:Integer;
  30.                             Tab:array[1..1] of ResEntry;
  31.                             end;
  32.     ResTabPtr = ^ResTab;
  33.     ResTabHandle = ^ResTabPtr;
  34.  
  35. var
  36.     i:Integer;
  37.     r:ResTabHandle;
  38.     Done:Boolean;
  39.  
  40. begin
  41.     GetResNum:=0;
  42.     Done:=False;
  43.     i:=1;
  44.     {Get the pointer to 4BND resource}
  45.     r:=POINTER(GetResource('4BND',CurProcResId));
  46.     {make sure we found the resource}
  47.     if r<> Nil then
  48.     begin
  49.         {Cycle thru all the entries in the}
  50.         {4BND resource}
  51.         while((i<=r^^.nbEntry) and
  52.             (Not(Done))) do
  53.             begin
  54.                 {loop until we find the one with}
  55.                 {the localID and the type we want}
  56.                 with r^^.Tab[i] do
  57.                 begin
  58.                     {check for a match}
  59.                     if (t=Typ) and
  60.                         (LocalNum=LocalId) then
  61.                     begin
  62.                         {we found it, so return the}
  63.                         {GlobalID to the calling routine}
  64.                         GetResNum:=GlobalNum;
  65.                         Done:=True;
  66.                     end;    {if}
  67.                 end;    {with}
  68.                 i:=i+1;    {increment our entry counter}
  69.         end;        {while}
  70.     end;        {if r<>Nil}
  71. end;        {GetResNum}
  72.  
  73.